<?php
// +----------------------------------------------------------------------
// | 07FLYSAAS [基于ThinkPHP5.0开发]
// +----------------------------------------------------------------------
// | Copyright (c) 2025-2035 http://www.07fly.xyz
// +----------------------------------------------------------------------
// | Professional because of focus  Persevering because of happiness
// +----------------------------------------------------------------------
// | Author: 开发人生 <goodkfrs@qq.com>
// +----------------------------------------------------------------------

namespace app\plat\controller;

use app\common\controller\ControllerBase;
use think\db;

/**
 * 用户控制器
 */
class TenDev extends PlatControllerBase
{
    public function __construct()
    {
        parent::__construct();
        // 验证登录
        !TEN_USER_ID && $this->redirect('plat/login/login');
        // 租户类型
        $tenant_type_list = $this->logicTenDev->getTenTenantTypeList(['visible'=>1], '', '', false);

        $this->assign('tenant_type_list', $tenant_type_list);
    }

    /**
     * 列表
     */
    public function show()
    {
        $list = $this->logicTenDev->getTenUserTenantList();
        foreach ($list as &$row){

            if($row['stop_date']<date('Y-m-d H:i:s')){
                $row['is_expire']='<span style="color:red">已到期</span>';
            }else{
                $row['is_expire']='<span style="color:green">正常</span>';
            }
        }
        $this->assign('list', $list);
        return $this->fetch('show');
    }

    // 租户初始化
    public function init()
    {
        IS_POST && $this->jump($this->logicTenDev->tenTenantInitUserData($this->param));
    }

    /**
     * 添加
     */
    public function add()
    {
        IS_POST && $this->jump($this->logicTenDev->tenTenantAdd($this->param));
        $html = '
        <div class="row white-bg" style="padding: 10px 5px 10px 20px;font-size: 13px;">
            <div class="col-sm-12">
                <ol class="breadcrumb">
                    <li><a><i class="fa fa-cogs"></i> 创建企业</a></li>
                </ol>
            </div>
        </div>
        ';
        // 面包屑视图
        $this->assign('crumbs_view', $html);

        $this->assign('pageTitle', '创建企业');

        return $this->fetch('add');
    }
}